

package io.contract;

import io.contract.service.BinanceService;
import io.contract.websocket.BinanceKlineWebSocketClient;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

import java.net.URI;

/**
 * contract-api
 *
 * @author allen
 */
@SpringBootApplication(scanBasePackages = {"io.contract"})
@MapperScan(value = "io.contract.**.dao")
@Slf4j
public class ApiApplication implements ApplicationRunner {

    @Resource
    BinanceService binanceService;

    public static void main(String[] args) {
        SpringApplication.run(ApiApplication.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        URI uri = new URI("wss://stream.binance.com:9443/ws/btcusdt@kline_1s");
        BinanceKlineWebSocketClient client = new BinanceKlineWebSocketClient(uri, binanceService);
        client.connect();
    }

}
